﻿using UnityEngine;
using System.Collections;

public class DebugHelper : MonoBehaviour 
{
	public bool m_drawGrid;
	public Camera m_mainCamera;
	private float m_tileHeight = 64.0f;
	private float m_tileWidth = 64.0f;
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		if( m_drawGrid )
		{
			//Horizontal Lines
			for( int i = Screen.height; i >= 0 ; i-=(int)m_tileHeight )
			{
				Debug.DrawLine(new Vector3( 0 + (m_mainCamera.transform.position.x - m_mainCamera.pixelRect.width * 0.5f), i + m_mainCamera.transform.position.y - m_mainCamera.pixelRect.height * 0.5f, 0), 
				               new Vector3( Screen.width + (m_mainCamera.transform.position.x - m_mainCamera.pixelRect.width * 0.5f), i + m_mainCamera.transform.position.y - m_mainCamera.pixelRect.height * 0.5f , 0), Color.red );
			}

			//Vertical Lines
			for( int i = Screen.width; i >= 0 ; i-=(int)m_tileWidth )
			{
				Debug.DrawLine(new Vector3( i+ (m_mainCamera.transform.position.x - m_mainCamera.pixelRect.width * 0.5f), Screen.height + m_mainCamera.transform.position.y - m_mainCamera.pixelRect.height * 0.5f, 0), 
				               new Vector3( i+ (m_mainCamera.transform.position.x - m_mainCamera.pixelRect.width * 0.5f), 0 + m_mainCamera.transform.position.y - m_mainCamera.pixelRect.height * 0.5f, 0), Color.yellow );
			}
		}
	}
}
